package com.yztc.ui.category;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.yztc.helper.RecyclerViewAdapterHelper;
import com.yztc.okbuy.R;

import java.util.List;

/**
 * Created by My on 2016/12/20.
 */

public class RecyclerIconAdapter extends RecyclerViewAdapterHelper<CartgroyBean.ResultsBean>{
    public RecyclerIconAdapter(Context context, List<CartgroyBean.ResultsBean> list) {
        super(context, list);
    }

    @Override
    public RecyclerView.ViewHolder onCreateMyViewHolder(ViewGroup parent, int viewType) {
        View view= LayoutInflater.from(context).inflate(R.layout.item_recycler_icon,parent,false);
        return new ViewHolder(view);
    }

    @Override
    public void onBindMyViewHolder(RecyclerView.ViewHolder holder, int position) {
        if(holder instanceof ViewHolder){
            Glide.with(context).load(list.get(position).getBrand_category()
                    .get(position).getBrand_picture()).into(((ViewHolder) holder).imageView_icon);
            ((ViewHolder) holder).textView_icon.setText(list.get(position).getBrand_category().get(position).getBrand_name());
//            Log.i("tag","+++++++++++++"+list.get(position).getBrand_category().get(position).getBrand_name());
        }
    }
   static class ViewHolder extends RecyclerView.ViewHolder{
        private ImageView imageView_icon;
        private TextView textView_icon;
        public ViewHolder(View itemView) {
            super(itemView);
            imageView_icon= (ImageView) itemView.findViewById(R.id.imageView_icon);
            textView_icon= (TextView) itemView.findViewById(R.id.textView_icon);
        }
    }
}
